#include <iostream>
#include <string>
using namespace std;
// find is a find way from left to right
void find()
{
	string str = "abababab";
	int position = str.find("a");
	cout<<position<<endl;
}
// and this in turn, 
// rfind is other find way from right to left
void rfind()
{
	string str = "abababab";
	int position = str.rfind("a");
	cout<<position<<endl;
}
void replace()
{
	string str = "I love Dota2";
	str.replace(1, 3, "111111");
	cout<<str<<endl;
}
void compare()
{
	string str = "Hello";
	string str1 = "Hello";
	cout<<str.compare(str1)<<endl;
}
void at()
{
	string str = "Hello";
	cout<<str.at(1)<<endl;
	cout<<str.size()<<endl;
}
void insert()
{
	string str = "People's Republic of China";
	str.insert(2, "000");
	cout<<str<<endl;
	str.erase(2, 3);
	cout<<str<<endl;
}
void substr()
{
	string str = "baicoool@163.com";
	int position = str.find("@");
	cout<<str.substr(0, position)<<endl;
}
int main(int argc, char const *argv[])
{
	find();
	rfind();
	replace();
	compare();
	at();
	insert();
	substr();
	return 0;
}